import {
  Entity,
  PrimaryGeneratedColumn,
  Column,
  CreateDateColumn,
  UpdateDateColumn,
} from 'typeorm';
import { ApiProperty } from '@nestjs/swagger';

@Entity()
export class User {
  @ApiProperty({ description: '用户ID', example: 1 })
  @PrimaryGeneratedColumn()
  id: number;

  @ApiProperty({ description: '用户名', example: 'user123' })
  @Column({ unique: true })
  username: string;

  @ApiProperty({ description: '密码', example: 'Password123!' })
  @Column()
  password: string;

  @ApiProperty({ description: '邮箱', example: 'user@example.com' })
  @Column({ unique: true })
  email: string;

  @ApiProperty({ description: '角色', example: 'user' })
  @Column({ default: 'user' })
  role: string;

  @ApiProperty({ description: '创建时间', example: '2023-01-01T00:00:00.000Z' })
  @CreateDateColumn()
  createdAt: Date;

  @ApiProperty({ description: '更新时间', example: '2023-01-01T00:00:00.000Z' })
  @UpdateDateColumn()
  updatedAt: Date;
}
